package cn.felord.common.service.impl;

import cn.felord.common.bean.Menu;
import cn.felord.common.entity.SysResources;
import cn.felord.common.entity.dto.ResourceRole;
import cn.felord.common.mapper.SysResourcesMapper;
import cn.felord.common.service.ISysResourcesService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 资源表 服务实现类
 * </p>
 *
 * @author dax
 * @since 2018-09-13
 */
@Service
public class SysResourcesServiceImpl extends ServiceImpl<SysResourcesMapper, SysResources> implements ISysResourcesService {
    @Resource
    private SysResourcesMapper sysResourcesMapper;



    @Cacheable(value = "resourcesRoleCache")
    @Override
    public List<ResourceRole> initUrlRoleStorage() {
        return sysResourcesMapper.initUrlRoleStorage();
    }

    @Override
    public LinkedHashSet<Menu> findMenuByUserId(String userId) {
        return sysResourcesMapper.findMenu(userId);
    }

    @Override
    public List<Map<String, Object>> findMenuByParentId(String parentId) {
        return sysResourcesMapper.findMenuByParentId(parentId);
    }
}
